/**
 * Copyright (c) 2004-2015 All Rights Reserved.
 */
package com.zbest.zpay.web.controller.activity;

import org.springframework.stereotype.Controller;

import com.zbest.zpay.web.controller.BaseController;

/**
 * 
 *
 * @author czhou3306@gmail.com
 * @version $Id: DocumentController.java, v0.1 2015年12月16日 下午5:03:15 czhou3306@gmail.com Exp $
 */
@Controller
public class DocumentController extends BaseController {/*

    @Resource
    private ActivityDocumentRepository activityDocumentRepository;

    *//**
     * 查询文档模板
     * 
     * @param request
     * @param loginForm
     * @return
     *//*
    @RequestMapping(value = "/document/queryTemplate", method = RequestMethod.POST)
    @ResponseBody
    public String queryTemplate(HttpServletRequest request,
                                @RequestBody DocumentTemplateQueryForm form) {

    //    Merchant merchant = (Merchant) request.getSession().getAttribute(ContextField.KEY_MERCHANT);
        Map<String, Object> data = new HashMap<String, Object>();
//        data.put(ContextField.KEY_MERCHANT_ID, merchant.getMerchantId());
        data.put(DocumentTemplateQueryForm.class.getSimpleName(), form);

        ProcessResult processResult = processService.execute(
            ProcessConstant.PROCESS_QUERY_DOCUMENT_TEMPLATE, data);

        if (processResult.isSuccess()) {
            return newSuccessResult(processResult.getResultObject());
        } else {
            return newErrorResult(processResult.getCode(), processResult.getCode().getMessage());
        }

    }

    *//**
     * 增加
     * 
     * @param request
     * @param loginForm
     * @return
     *//*
    @RequestMapping(value = "/document/add", method = RequestMethod.POST)
    @ResponseBody
    public String add(HttpServletRequest request, @RequestBody DocumentForm form) {

        Merchant merchant = (Merchant) request.getSession().getAttribute(ContextField.KEY_MERCHANT);
        Map<String, Object> data = new HashMap<String, Object>();
        data.put(ContextField.KEY_MERCHANT_ID, merchant.getMerchantId());
        data.put(DocumentForm.class.getSimpleName(), form);

        ProcessResult processResult = processService.execute(ProcessConstant.PROCESS_ADD_DOCUMENT,
            data);

        if (processResult.isSuccess()) {
            return newSuccessResult(processResult.getResultObject());
        } else {
            return newErrorResult(processResult.getCode(), processResult.getCode().getMessage());
        }
    }

    *//**
     * 查询文档
     * 
     * @param request
     * @param loginForm
     * @return
     *//*
    @RequestMapping(value = "/document/queryEditContent", method = RequestMethod.GET)
    @ResponseBody
    public String queryEditContent(HttpServletRequest request, @RequestParam String documentId) {

        Merchant merchant = (Merchant) request.getSession().getAttribute(ContextField.KEY_MERCHANT);
        Map<String, Object> data = new HashMap<String, Object>();
        data.put(ContextField.KEY_MERCHANT_ID, merchant.getMerchantId());
        data.put(ContextField.KEY_DOCUMENT_ID, documentId);

        ProcessResult processResult = processService.execute(
            ProcessConstant.PROCESS_QUERY_DOCUMENT, data);

        if (processResult.isSuccess()) {
            ActivityDocument document = (ActivityDocument) processResult
                .get(ContextField.KEY_DOCUMENT);

            return document.getEditContent();
        } else {
            return newErrorResult(processResult.getCode(), processResult.getCode().getMessage());
        }

    }

    *//**
     * 查询文档
     * 
     * @param request
     * @param loginForm
     * @return
     *//*
    @RequestMapping(value = "/document/queryPublishContent", method = RequestMethod.GET)
    @ResponseBody
    public String queryPublishContent(HttpServletRequest request, @RequestParam String documentId) {

        ActivityDocument document = activityDocumentRepository.getDocument(documentId);
        if (document != null) {
            return document.getPublishContent();
        } else {
            return null;
        }
    }

    *//**
     * 更新document
     * 
     * @param request
     * @param loginForm
     * @return
     *//*
    @RequestMapping(value = "/document/update", method = RequestMethod.POST)
    @ResponseBody
    public String update(HttpServletRequest request, @RequestBody DocumentForm form) {

        Merchant merchant = (Merchant) request.getSession().getAttribute(ContextField.KEY_MERCHANT);
        Map<String, Object> data = new HashMap<String, Object>();
        data.put(ContextField.KEY_MERCHANT_ID, merchant.getMerchantId());
        data.put(DocumentForm.class.getSimpleName(), form);

        ProcessResult processResult = processService.execute(
            ProcessConstant.PROCESS_UPDATE_DOCUMENT, data);

        if (processResult.isSuccess()) {

            return newSuccessResult();
        } else {
            return newErrorResult(processResult.getCode(), processResult.getCode().getMessage());
        }
    }

    *//**
     * 发布文档
     * 
     * @param request
     * @param form
     * @return
     *//*
    @RequestMapping(value = "/document/publish", method = RequestMethod.POST)
    @ResponseBody
    public String publish(HttpServletRequest request, @RequestBody DocumentForm form) {

        Merchant merchant = (Merchant) request.getSession().getAttribute(ContextField.KEY_MERCHANT);
        Map<String, Object> data = new HashMap<String, Object>();
        data.put(ContextField.KEY_MERCHANT_ID, merchant.getMerchantId());
        data.put(DocumentForm.class.getSimpleName(), form);

        ProcessResult processResult = processService.execute(
            ProcessConstant.PROCESS_PUBLISH_DOCUMENT, data);

        if (processResult.isSuccess()) {

            return newSuccessResult();
        } else {
            return newErrorResult(processResult.getCode(), processResult.getCode().getMessage());
        }
    }

    *//**
     * 把活动转换成模板
     * 
     * @param request
     * @param form
     * @return
     *//*
    @RequestMapping(value = "/document/activityToTemplate", method = RequestMethod.POST)
    @ResponseBody
    public String activityToTemplate(HttpServletRequest request,
                                     @RequestBody ActivityToTemplateForm form) {

        Merchant merchant = (Merchant) request.getSession().getAttribute(ContextField.KEY_MERCHANT);
        Map<String, Object> data = new HashMap<String, Object>();
        data.put(ContextField.KEY_MERCHANT_ID, merchant.getMerchantId());
        data.put(ContextField.KEY_ACTIVITY_ID, form.getActivityId());
        data.put(ContextField.KEY_AMOUNT, form.getAmount());

        ProcessResult processResult = processService.execute(
            ProcessConstant.PROCESS_ACTIVITY_TO_TEMPLATE, data);

        if (processResult.isSuccess()) {

            return newSuccessResult();
        } else {
            return newErrorResult(processResult.getCode(), processResult.getCode().getMessage());
        }
    }

*/}
